package com.huangfu.learning.javabase.java.base;

/**
 * Created with IntelliJ IDEA.
 * Author: huangfu.daohui
 * Date: 2018/7/13
 * Time: 10:02
 * Version: 1.0
 * Description: 实例化接口，匿名内部类
 * 通过构造函数传递接口，然后实例化的时候去实现
 **/

interface Isay {
    void sayHello();
}

public class InstenceInterface {

    public InstenceInterface(Isay say) {
        say.sayHello();
    }

    public static void main(String[] args) {
        InstenceInterface instenceInterface = new InstenceInterface(new Isay() {
            @Override
            public void sayHello() {
                System.out.println("我是匿名内部类");
                System.out.println("Class对象是:" + this.getClass());
                System.out.println("类名字是:" + this.getClass().getSimpleName());
                System.out.println("hello");
            }
        });
    }
}
